<!DOCTYPE html>
<html class="" lang="en">
<head  >

    {% include 'twig/common/header/include.twig' %}
    <script src="/dev/js/admin/setting.js?v={{_version}}" type="text/javascript" charset="utf-8"></script>
    <script src="/dev/lib/handlebars-v4.0.10.js" type="text/javascript" charset="utf-8"></script>
    <script src="/dev/js/handlebars.helper.js?v={{_version}}" type="text/javascript" charset="utf-8"></script>
    <script src="/dev/js/admin/jstree/dist/jstree.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" href="/dev/js/admin/jstree/dist/themes/default/style.min.css"/>
    <style>
        .text-muted {
            color: #777777;
        }
        label {
            display: inline-block;
            max-width: 100%;
            margin-bottom: 5px;
            font-weight: bold;
        }

        .modal .modal-content .modal-body {
            padding: 15px 30px 0;
        }

        .role-table {
            padding: 0 20px;
        }
    </style>

</head>
<body class="" data-group="" data-page="projects:issues:index" data-project="xphp">
{% include 'twig/common/body/script.twig' %}

<section class="has-sidebar page-layout max-sidebar">
    {% include 'twig/common/body/page-left.twig' %}

    <div class="page-layout page-content-body system-page">
{% include 'twig/common/body/header-content.twig' %}

<script>
    var findFileURL = "";
</script>
<div class="page-with-sidebar">
    {% include 'twig/admin/common-page-nav-admin.twig' %}


    <div class="content-wrapper page-with-layout-nav page-with-sub-nav">
        <div class="alert-wrapper">

            <div class="flash-container flash-container-page">
            </div>

        </div>
        <div class="container-fluid ">

            <div class="content" id="content-body">

                {% include 'twig/admin/common_system_left_nav.twig' %}
                <div class="row has-side-margin-left">
                    <div class="col-lg-12">
                        <div class="top-area">
                            <ul class="nav-links">
                                <li class="active">
                                    <a href="#">全局权限角色</a>
                                </li>
                            </ul>
                            <div class="nav-controls">
                                <div class="btn-group" role="group">
                                </div>
                            </div>
                        </div>
                        <div class="content-list">
                            <div class="bs-callout bs-callout-warning shared-runners-description hidden">
                              <p>你可以使用项目角色来将用户或用户组关联到指定项目中。 下面表格显示Masterlab中所有可用的项目角色。 这个页面可以添加,编辑以及删除项目角色。 你可以通过点击 '查看方案应用' 来查看每个项目中项目角色的权限 方案以及通知方案。</p>
                            </div>
                            <div class="row" style="margin-top: 10px">
                                <form id="form_add" class="js-requires-input" action="/admin/system/global_permission_role_add"
                                      accept-charset="UTF-8" method="post">
                                    <div class="form-group col-md-1">
                                        <a class="btn btn-transparent" style="cursor:default">
                                        <strong class="append-right-5" >添加角色:</strong>
                                        </a>
                                    </div>
                                    <div class="form-group col-md-3">
                                        <input style="margin-left: -15px;" type="text" name="params[name]" maxlength="20" id="role_name" placeholder="角色名称" required="required" class="form-control">

                                    </div>
                                    <div class="form-group col-md-5">
                                        <input type="text" name="params[description]" id="role_description" maxlength="250" placeholder="描 述" class="form-control">

                                    </div>
                                    <div class="form-group col-md-3">
                                        <input id="btn-role_add" type="button" value="添 加" class="btn btn-create" >
                                    </div>
                                </form>
                            </div>
                            <div class="content">
                            </div>
                            <ul id="render" class="projects-list brd-bottom">
                            </ul>
                        </div>
                    </div>
                </div>


            </div>
            
        </div>
    </div>
</div>

    </div>
</section>


<div class="modal" id="modal-role_edit">
    <form class="js-quick-submit js-upload-blob-form form-horizontal" id="form_edit"
          action="#"
          accept-charset="UTF-8"
          method="post">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <a class="close" data-dismiss="modal" href="#">×</a>
                    <h3 class="modal-header-title">编辑全局角色</h3>
                </div>

                <div class="modal-body">
                    <input type="hidden" name="id" id="edit_id" value="">
                    <input type="hidden" name="format" id="format" value="json">

                    <div class="form-group">
                        <label class="control-label" >角色名:</label>
                        <div class="col-sm-5">
                            <div class="form-group">
                                <input type="text" class="form-control" placeholder="" name="params[name]" id="edit_name" value="" maxlength="20">
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label" >描述:</label>
                        <div class="col-sm-5">
                            <div class="form-group">
                                <textarea placeholder="" class="form-control" rows="3" maxlength="250" name="params[description]" id="edit_description"></textarea>
                            </div>
                        </div>
                    </div>

                </div>

                <div class="modal-footer">
                    <button name="edit_role_save" type="button" class="btn  btn-create " id="btn-update">保存</button>
                    <a class="btn btn-cancel" data-dismiss="modal" href="#">取消</a>
                </div>
            </div>
        </div>
    </form>
</div>


<div class="modal fade" id="modal-permission_edit" data-keyboard=true role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <form class="js-quick-submit js-upload-blob-form form-horizontal" id="form_permission_edit"
          action="/admin/system/update_perm"
          accept-charset="UTF-8"
          method="post">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <a class="close" data-dismiss="modal" href="#">×</a>
                    <h3 class="modal-header-title">权限分配</h3>
                </div>

                <div class="modal-body">
                    <input type="hidden" name="role_id" id="perm_role_id" value="">
                    <input type="hidden" name="permission_ids" id="permission_ids" value="">

                    <div class="form-group">
                        <label class="control-label">角色名称:</label>
                        <div class="col-sm-5">
                            <div class="form-group" >
                                <input type="text" class="form-control" disabled placeholder="" name="perm_role_name" id="perm_role_name" value="">
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label" for="id_font_icon">权限分配:</label>
                        <div class="col-sm-6">
                            <div class="form-group" style="margin-top: 7px;">
                                <span class="text-muted"><input type="checkbox" name="" id="checkall"> <label for="checkall"><small>选中全部</small></label></span>
                                <div id="container">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button name="btn-permission_update" type="button" class="btn btn-save" id="btn-permission_update">保存</button>
                    <a  class="btn btn-cancel" data-dismiss="modal" href="#">取消</a>
                </div>
            </div>
        </div>
    </form>
</div>



<div class="modal" id="modal-role_user">
    <form class="js-quick-submit js-upload-blob-form form-horizontal" id="form-role_user"
          action="#"
          accept-charset="UTF-8"
          method="post">
        <input type="hidden" name="role_id" id="role_user-role_id" value="">
        <input type="hidden" name="format" id="format" value="json">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <a class="close" data-dismiss="modal" href="#">×</a>
                    <h3 class="modal-header-title">角色用户</h3>
                </div>

                <div class="modal-body min-height400">

                    <div class="form-group">
                        <label class="control-label" >请选择用户:</label>
                        <div class="row">
                            <div class="col-md-6">

                                <div class="issuable-form-select-holder">
                                    <input type="hidden" value="" name="params[select_user]" id="role_user_selected_user_id" />
                                    <div class="dropdown ">
                                        <button class="dropdown-menu-toggle js-multiselect  js-dropdown-keep-input js-user-search js-issuable-form-dropdown js-assignee-search"
                                                type="button"
                                                data-onSelectedFnc="addGlobalPermRoleUser"
                                                data-first-user="{{user['username']}}"
                                                data-null-user="true"
                                                data-current-user="true"
                                                data-project-id=""
                                                data-field-name="params[select_user]"
                                                data-default-label=""
                                                data-selected=""
                                                data-toggle="dropdown">
                                            <span class="dropdown-toggle-text is-default">点击选择用户</span>
                                            <i class="fa fa-chevron-down"></i>
                                        </button>

                                        <div class="dropdown-menu dropdown-select dropdown-menu-user dropdown-menu-selectable dropdown-menu-assignee js-filter-submit">
                                            <div class="dropdown-title">
                                                <span>选择用户</span>
                                                <button class="dropdown-title-button dropdown-menu-close" aria-label="Close" type="button">
                                                    <i class="fa fa-times dropdown-menu-close-icon"></i>
                                                </button>
                                            </div>
                                            <div class="dropdown-input">
                                                <input type="search" id="" class="dropdown-input-field" placeholder="Search assignee" autocomplete="off" />
                                                <i class="fa fa-search dropdown-input-search"></i>
                                                <i role="button" class="fa fa-times dropdown-input-clear js-dropdown-input-clear"></i>
                                            </div>
                                            <div class="dropdown-content "></div>
                                            <div class="dropdown-loading">
                                                <i class="fa fa-spinner fa-spin"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <a class="assign-to-me-link " href="#">选择自己</a>

                                <script>
                                    new UsersSelect();
                                </script>

                            </div>
                            <!--<div class="col-md-3">
                                <button id="btn-role_user_save" name="btn-role_user_save" type="button" class="btn " >添 加</button>
                            </div>-->
                        </div>
                    </div>

                    <div class="role-table">
                        <div class="form-group">
                            <table class="table ci-table">
                                <tbody id="role_user_list_render_id">

                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <a class="btn btn-cancel" data-dismiss="modal" href="#">关 闭</a>
                </div>
            </div>
        </div>
    </form>
</div>
{% verbatim %}<script type="text/html"  id="role_user_list_tpl">
    {{#role_users}}
    <tr class="commit" id="role_user_id_{{id}}">
        <td>{{user_html user_id}}</td>
        <td>{{user_account_str user_id}}</td>
        <td>
            {{#if_eq root '1'}}
            {{^}}
            <a class="role_user_remove btn btn-transparent "
               href="javascript:;"
               data-id="{{id}}"
               data-user_id="{{user_id}}"
               data-role_id="{{role_id}}"
               data-value="{{user_id}}">
                <i class="fa fa-trash"></i><span class="sr-only">移除</span>
            </a>
            {{/if_eq}}
        </td>
    </tr>
    {{/role_users}}
</script>{% endverbatim %}



{% verbatim %}<script type="text/html" id="render_tpl">
    {{#roles}}
    <li class="member project_member" id="{{id}}">
        <span class="list-item-name">
            <strong>
                {{name}}
            </strong>
          <div class="hidden-xs cgray">{{description}}</div>
        </span>
        <div class="controls member-controls ">

            <a class="list_edit_perm prepend-left-10" rel="nofollow" data-id="{{id}}" data-name="{{name}}"  href="#">
                权 限
            </a>
            <a class="list_add_user prepend-left-10" rel="nofollow" data-id="{{id}}"  href="#">
                用 户
            </a>
            {{#if_eq is_system '1'}}
            {{^}}
            <a class="list_for_edit prepend-left-10" rel="nofollow" data-id="{{id}}"  href="#">
                编 辑
            </a>
            <a class="list_for_delete prepend-left-10" rel="nofollow" data-id="{{id}}"  href="#">
                删 除
            </a>
            {{/if_eq}}
        </div>
    </li>
    {{/roles}}
</script>{% endverbatim %}

<script type="text/javascript">
    var _issueConfig = {
        users:{{users|json_encode()|raw}}
    };
    $(function() {
        fetchPermissionGlobalRole('/admin/system/fetch_global_permission_role','render_tpl','render');
    });

</script>

</body>
</html>
